#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: api17_shareCache.py 
@version:
@time: 2022/05/26 
"""
from TapClientCore.T02_tm_api.v2_api.v2_api_base import *


class Api17ShareCacheUrl(V2ApiUrlBase):
    url_shareCache = api_joint(V2ApiUrlBase().server, 'shareCache')


class Api17ShareCache(V2ApiBase, Api17ShareCacheUrl):

    def get_share_cache(self, _filter):
        response = self.tapclient(
            self.get,
            self.url_shareCache
            + self.access_token
            + self.filter(_filter)
        )
        return response

    def delete_share_cache_by_id(self, id):
        response = self.tapclient(
            self.delete,
            api_joint(self.url_shareCache, id)
            + self.access_token
        )
        return response

    """
    var cachedRow = CacheService.getCache( 'robotcache' , record.pk );
    record.category_name = cachedRow.category_name;
    """

    def post_share_cache(self, payload):
        response = self.tapclient(
            self.post,
            self.url_shareCache
            + self.access_token,
            json=payload
        )
        return response

